package org.smile.strate.dispatch;

import org.smile.strate.ActionConstants;

public class ActionURLInfo {
	/**原本uri*/
	protected String uri;
	/**从uri中解析出的命名空间*/
	protected String namespace;
	/**解析出的action名称*/
	protected String actionName;
	/**是否是后缀方式*/
	protected boolean suffix=true;
	/**action标识*/
	protected String actionFlag=ActionConstants.extension;
	/**uri中的参数值*/
	protected String[] uriArgs;
	/**是否被改过*/
	protected boolean changed=false;
	
	protected boolean needToAction=false;
	
	public ActionURLInfo(String namespace,String actionName){
		this.namespace=namespace;
		this.actionName=actionName;
	}

	public void setNamespace(String namespace) {
		this.namespace = namespace;
	}

	public void setActionName(String actionName) {
		this.actionName = actionName;
	}

	public String getNamespace() {
		return namespace;
	}

	public String getActionName() {
		return actionName;
	}

	public String[] getUriArgs() {
		return uriArgs;
	}

	public void setUriArgs(String[] uriArgs) {
		this.uriArgs = uriArgs;
	}
	
	public boolean isSuffix() {
		return suffix;
	}

	public void setSuffix(boolean suffix) {
		this.suffix = suffix;
	}

	public String getActionFlag() {
		return actionFlag;
	}

	public void setActionFlag(String actionFlag) {
		this.actionFlag = actionFlag;
	}

	public String toActionURI() {
		StringBuilder str=new StringBuilder();
		if(!suffix) {
			str.append("/").append(actionFlag);
		}
		str.append("/").append(namespace);
		str.append("/").append(actionName);
		if(suffix) {
			str.append(".").append(actionFlag);
		}
		return str.toString();
	}

	public String getUri() {
		return uri;
	}

	public void setUri(String uri) {
		this.uri = uri;
	}

	public boolean isChanged() {
		return changed;
	}

	public void setChanged(boolean changed) {
		this.changed = changed;
	}

	public boolean isNeedToAction() {
		return needToAction;
	}

	public void setNeedToAction(boolean needToAction) {
		this.needToAction = needToAction;
	}
	
}
